package 洛谷;

import java.util.Arrays;
import java.util.Scanner;

public class k倍区间 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] a = new int[n + 1];
        int[] sum = new int[n + 1];
        int[] mp = new int[k];
        Arrays.fill(mp, 0);
        mp[0] = 1;
        long ans = 0;
        for (int i = 1; i <= n; i++) {
            a[i] = sc.nextInt();
            sum[i] = (sum[i - 1] + a[i]) % k;
            ans += mp[sum[i]];
            mp[sum[i]]++;
        }
        System.out.println(ans);
    }
}
